﻿<!--TO READ THIS HELP FILE, RIGHT-CLICK ON THE FILE NAME IN THE
    SOLUTION EXPLORER PANE AND SELECT "VIEW IN BROWSER"-->

<html><head><title>COM Interop Part 2 Sample</title></head><body><h1>COM Interop Part 2 Sample</h1><div id="mainSection"><div id="mainBody"><div id="allHistory" class="saveHistory" onsave="saveAll()" onload="loadAll()"></div><p /><p>This sample demonstrates using a C# server with a C++ COM client.</p><div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note </th></tr><tr><td><p>
	You must run Visual Studio as an administrator and Visual C++ must be 
	installed to compile this sample.</p></td></tr></table></div><div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Security Note </th></tr><tr><td><p>This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.</p></td></tr></table></div><h1 class="heading">To build and run the COM Interop Part 2 sample within Visual Studio</h1><div id="procedureSection1" class="section"><ol><li><p>
	If you are running Windows Vista, right-click the <strong>Visual Studio 2008</strong> 
	shortcut on the Start Menu and choose <strong>Run as administrator</strong> 
	when loading the development environment.</p>
	</li>
	<li>
	<p>In <b>Solution Explorer</b>, right-click the COMClient project and click <b>Properties</b>.</p></li><li><p>Open the Configuration Properties folder, and click <b>Debug</b>.</p></li><li><p>In the Command Line Arguments property, enter a name.</p></li><li><p>Click <b>OK</b>.</p></li><li><p>From the <b>Debug</b> menu, click <b>Start Without Debugging</b>.</p></li></ol></div><h1 class="heading">To build and run the COM Interop Part 2 sample from the Command Line</h1><div id="procedureSection2" class="section"><ol><li><p>
		If you are running Windows Vista, right-click the <strong>Command Prompt</strong> 
		shortcut on the Start Menu and choose <strong>Run as administrator</strong> 
		when loading the command prompt.</p>
		</li>
		<li>
		<p>Use the <b>Change Directory</b> command to change to the COMInteropPart2\COMClient directory.</p></li><li><p>Copy the C# server code into the COMClient directory: </p><div class="code"><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><td colspan="2"><pre>copy ..\CSharpServer\CSharpServer.cs</pre></td></tr></table></span></div></li><li><p>Compile the server: </p><div class="code"><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><td colspan="2"><pre>csc /target:library CSharpServer.cs
regasm CSharpServer.dll /tlb:CSharpServer.tlb</pre></td></tr></table></span></div></li><li><p>Compile the client (make sure the path and environment variables are set properly with vcvars32.bat): </p><div class="code"><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><td colspan="2"><pre>cl COMClient.cpp</pre></td></tr></table></span></div></li><li><p>Run the client: </p><div class="code"><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><td colspan="2"><pre>COMClient friend</pre></td></tr></table></span></div></li></ol></div></div><div id="footer"><div class="footerLine"></div>
        To make a suggestion or report a bug about Help or another feature of this product, go to the <a href="http://go.microsoft.com/fwlink/?LinkId=50040">feedback site</a>.
      </div></div></body></html>
